package com.yidu.controller;

import com.yidu.entity.Book;
import com.yidu.service.BookService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class BookController {
    @Resource
    BookService bookService;
    @RequestMapping("/selectBook")
    @ResponseBody
    public Map selectBook (int page, int limit){
        List<Book> bookList = bookService.selectBook(page, limit);
        Map map = new HashMap(); 
        map.put("code",0);
        map.put("msg",":");
        map.put("count",100);
        map.put("data",bookList);
        return map;
    }
    @RequestMapping("/insertBook")
    public void insertBook(Book book){
        bookService.insertBook(book);
    }
    @RequestMapping("/updateBook")
    public void updateBook(Book book){
        bookService.updateBook(book);
    }
    @RequestMapping("/deleteBook")
    public void deleteBook(String bookId){
        bookService.deleteBook(bookId);
    }
    @RequestMapping("/Book")
    public String Book(){
        return "Book";
    }
    @RequestMapping("/Permissions")
    public String Permissions(){
        return "Permissions";
    }
}
